﻿using System;
using System.Data;
using System.Data.Common;
using System.Text;

namespace DatabaseAccess
{
    public class MShortConnection: DBAccess
    {
        public MShortConnection(string connectionString):
            base(connectionString,SqlType.PostgresQL)
        {
        
        }

        /// <summary>
        /// 执行非Select语句，包括UPDATE DELETE INSERT
        /// </summary>
        /// <param name="strSQL">需要执行的sql语句</param>
        /// <returns>受影响的行数</returns>
        public override int ExcuteNonQuery(string strSQL)
        {
            DbCommand myCmd = GetCommand(db, strSQL);
            try
            {
                int ret = myCmd.ExecuteNonQuery();
                myCmd.Dispose();
                return ret;
            }
            catch (Exception ex)
            {
                myCmd.Dispose();
                StringBuilder sb = new StringBuilder();
                sb.Append(strSQL+"\r\n");
                sb.Append(ex.ToString());
                throw new Exception(sb.ToString());
            }
        }
    }
}
